package com.ruicar.afs.cloud.basic.proceeds.pay.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruicar.afs.cloud.basic.proceeds.pay.entity.BasicPaymentPool;
import com.ruicar.afs.cloud.basic.proceeds.pay.entity.BasicPaymentRecord;
import com.ruicar.afs.cloud.basic.proceeds.pay.mapper.BasicPaymentRecordMapper;
import com.ruicar.afs.cloud.basic.proceeds.pay.service.BasicPaymentRecordService;
import com.ruicar.afs.cloud.common.modules.contract.enums.PaymentRecordEnum;
import com.ruicar.afs.cloud.common.modules.contract.enums.PaymentStatusEnum;
import org.springframework.stereotype.Service;

import java.util.Calendar;

/**
 * @author: Lee
 * @date 2020-05-30 04:35:07 
 * @description 
 */
@Service
public class BasicPaymentRecordServiceImpl extends ServiceImpl<BasicPaymentRecordMapper, BasicPaymentRecord> implements BasicPaymentRecordService {


    @Override
    public BasicPaymentRecord addPaymentRecord(BasicPaymentPool paymentPool,PaymentRecordEnum status,PaymentStatusEnum paymentStatus) {
        BasicPaymentRecord paymentRecord = new BasicPaymentRecord();
        paymentRecord.setPoolId(paymentPool.getId());
        paymentRecord.setPaymentBankCode(paymentPool.getPaymentBankCode());
        paymentRecord.setPaymentAccount(paymentPool.getPaymentAccount());
        paymentRecord.setPaymentAccountName(paymentPool.getPaymentAccountName());
        paymentRecord.setPaymentAmt(paymentPool.getPaymentAmt());
        paymentRecord.setReceiptBankCode(paymentPool.getReceiptBankCode());
        paymentRecord.setReceiptBankName(paymentPool.getReceiptBankName());
        paymentRecord.setReceiptEbankCode(paymentPool.getReceiptEbankCode());
        paymentRecord.setReceiptAccount(paymentPool.getReceiptAccount());
        paymentRecord.setReceiptAccountName(paymentPool.getReceiptAccountName());
        paymentRecord.setOperateTime(Calendar.getInstance().getTime());
        paymentRecord.setStatus(status);
        paymentRecord.setPaymentResult(paymentStatus);
        paymentRecord.setCallBackTime(null);
        paymentRecord.setCallBackMsg(null);
        paymentRecord.setRemarks(null);
        this.save(paymentRecord);
        return  paymentRecord;
    }
}
